package cn.edu.nju.oraldefense.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.edu.nju.oraldefense.dao.CommentDao;
import cn.edu.nju.oraldefense.model.Comment;
import cn.edu.nju.oraldefense.model.Paper;
import cn.edu.nju.oraldefense.model.Teacher;
import cn.edu.nju.oraldefense.service.CommentService;

@Component("commentService")
public class CommentServiceImpl implements CommentService {

	private CommentDao commentDao;

	public CommentDao getCommentDao() {
		return commentDao;
	}

	@Resource
	public void setCommentDao(CommentDao commentDao) {
		this.commentDao = commentDao;
	}

	public Comment getById(int id) {
		return commentDao.findById(id);
	}

	public List getByPaper(Paper paper) {
		return commentDao.findByPaper(paper);
	}

	public List getByTeacherAndMonth(Teacher teacher, String yearmonth,String nextyearmonth) {
		return commentDao.findByTeacherAndMonth(teacher, yearmonth,nextyearmonth);
	}

	public void addComment(Comment c) {
		commentDao.save(c);
	}

	public void removeComment(Comment c) {
		commentDao.delete(c);
	}

	public void modifyComment(Comment c) {
		commentDao.update(c);
	}

}
